package com.ybwh.springboot2.example;


import com.ybwh.springboot2.common.RespData;
import com.ybwh.springboot2.common.enums.CodeTextEnumView;
import com.ybwh.springboot2.common.enums.EnumHub;
import com.ybwh.springboot2.enums.HobyEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@Api(tags="常见例子")
@RestController
@RequestMapping("/example")
public class ExampleController {


    @ApiOperation(value = "字段打码和枚举名称显示",notes = "")
    @RequestMapping(value = "/mask", method = RequestMethod.GET)
    public RespData<Person> mask() {
        Person p = new Person();
        p.setBase(new Base(HobyEnum.football.getCode()));
        p.setAge(30);
        p.setName("mikesrytryeruututututtu");
        p.setBirthday(LocalDateTime.now());
        p.setHoby(HobyEnum.basketball.getCode());

        return RespData.successResp(p);
    }




    @ApiOperation(value = "枚举验证",notes = "")
    @RequestMapping(value = "/validEnum", method = RequestMethod.POST)
    public RespData<Person> validEnum(@Validated @RequestBody Person p){


          return RespData.successResp(p);

    }

    @ApiOperation(value = "枚举下拉框",notes = "")
    @RequestMapping(value = "/emumList", method = GET)
    public List<CodeTextEnumView> versionInformation(@RequestParam("enumId") String enumId) {

        return EnumHub.getCodeTextEnumViewList(enumId);


    }



}
